<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>123</div>
    <script>
        //获取事件源
        var div1 = document.querySelector('div');
        //绑定事件 注册事件
        //添加事件处理程序
        div1.onclick = function() {
            console.log('我被选中了')
        }
    </script>
</body>

</html>